package com.nuaa.community.util;

import com.nuaa.community.entity.User;
import org.springframework.stereotype.Component;

/**
 * ClassName: HostHolder
 * Package: com.nuaa.community.util
 * Description:持有用户信息，用于代替session对象
 */
@Component
public class HostHolder {
      private ThreadLocal<User> users =  new ThreadLocal<>();

      public void setUsers(User user){
          users.set(user);
      }

      public User getUser(){
          return users.get();
      }

      public void clear(){
          users.remove();
      }

}
